package 力扣日常刷题.木22二月.第22天228;

/**
 * @author 帅小伙
 * @date 2022/2/28
 * @description
 */
public class Demo182好字符串 {


    public static void main(String[] args) {
        areOccurrencesEqual("bbbbbbb");
    }

    public static boolean areOccurrencesEqual(String s) {
        int[] arr = new int[26];
        for(char c : s.toCharArray()) {
            arr[c - 'a'] ++;
        }
        int useful = -1;

        for(int i = 0; i < 26; i ++){
            if(useful == -1 && arr[i] != 0) {
                useful = arr[i];
            }

            if(arr[i]!= 0 && arr[i]!= useful) return false;
        }
        return true;

    }

}
